package net.cjw.initsb.service.impl;

import java.util.Date;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import net.cjw.initsb.common.ServiceResult;
import net.cjw.initsb.dao.QuartzTaskLogMapper;
import net.cjw.initsb.entity.QuartzTaskLog;
import net.cjw.initsb.service.QuartzTaskLogServiceI;
import net.cjw.initsb.utils.UUIDBuild;

@Service
@Transactional
public class QuartzTaskLogServiceImpl implements QuartzTaskLogServiceI {

	Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private QuartzTaskLogMapper quartzTaskLogMapper;

	@Override
	public ServiceResult<String> create(QuartzTaskLog entity) {

		entity.setCreateTime(new Date());
		entity.setId(UUIDBuild.createUUId());
		quartzTaskLogMapper.insertSelective(entity);

		return ServiceResult.buildSuccess();
	}

	@Override
	public ServiceResult<String> update(QuartzTaskLog entity) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ServiceResult<String> delete(QuartzTaskLog entity) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ServiceResult<QuartzTaskLog> selectOne(QuartzTaskLog entity) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ServiceResult<Object> selectAll(Integer start, Integer max) {
		PageHelper page = new PageHelper();
		page.startPage(start, max);
		List<QuartzTaskLog> list = quartzTaskLogMapper.selectAll();
		PageInfo<QuartzTaskLog> pageInfo = new PageInfo<QuartzTaskLog>(list);
		return ServiceResult.buildSuccess(list, pageInfo.getTotal());
	}

}
